package com.getword.service.impl;

import com.getword.domain.Grade;
import com.getword.mongodao.GradeRepository;
import com.getword.service.GradeService;
import com.getword.web.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Transactional(readOnly = false)
public class GradeServiceImpl implements GradeService {
    @Autowired
    private GradeRepository gradeRepository;

    @Override
    public Result addGrade(Grade grade) {
        Grade save = gradeRepository.save(grade);
        return Result.success(grade, null);
    }

    @Override
    public Result getGrade() {
        List<Grade> grades = gradeRepository.findAll();
        return Result.success(grades);
    }
}
